package com.example.oneAgent;



import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class PredicateTest {
    public static void main(String[] args) {
        String bondtypeCondition = "bondtype1";
        String wmcCondition = "wmc1";
        String fundhouseidCondition = "";
        String fundassettypeCondition = "";
        String risklevel1Condition = "risklevel1";
        List<BB> lvTempInfoList = new ArrayList<>();
        lvTempInfoList.add(new BB("fundhouseid1","bondtype1","wmc1","fundassettype1","risklevel1"));
        lvTempInfoList.add(new BB("fundhouseid1","bondtype1","wmc1","fundassettype1","risklevel1"));
        lvTempInfoList.add(new BB("fundhouseid2","bondtype3","wmc4","fundassettype2","risklevel1"));
        lvTempInfoList.add(new BB("","bondtype1","wmc1","","risklevel1"));
        for (BB bb : lvTempInfoList) {
            System.out.println(bb);
        }
        System.out.println("=========================================");
        Predicate<BB> lvPredicate = new Predicate<BB>() {
            @Override
            public boolean test(BB pInput)
            {
                if (!ObjectUtils.isNullString(bondtypeCondition) && !bondtypeCondition.equals(pInput.getBondType()))
                    return false;
                if (!ObjectUtils.isNullString(wmcCondition) && !wmcCondition.equals(pInput.getWmc()))
                    return false;
                if (!ObjectUtils.isNullString(fundhouseidCondition) && !fundhouseidCondition.equals(pInput.getFundHouseID()))
                    return false;
                if (!ObjectUtils.isNullString(fundassettypeCondition) && !fundassettypeCondition.equals(pInput.getFundAssetType()))
                    return false;
                if (!ObjectUtils.isNullString(risklevel1Condition) && !risklevel1Condition.equals(pInput.getRiskLevel()))
                    return false;
                return true;
            }
        };
        lvTempInfoList = lvTempInfoList.stream().filter(lvPredicate).collect(Collectors.toList());
        for (BB bb : lvTempInfoList) {
            System.out.println(bb);
        }

    }
}
